home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6229 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  58 lines

  1. Path: huxley.mv.us.adobe.com!user
  2. From: pchang@adobe.com (The Weasel)
  3. Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++
  4. Subject: Re: using a template parameter as a qualifier -- legal or not?
  5. Date: Fri, 09 Feb 1996 09:43:13 -0800
  6. Organization: Adobe Systems
  7. Message-ID: <pchang-0902960943130001@huxley.mv.us.adobe.com>
  8. References: <rshapiro-0602961258310001@esb.bbn.com> <3117C2B0.41C6@tiger.physics.utoronto.ca>
  9. NNTP-Posting-Host: huxley.mv.us.adobe.com
  10.  
  11. > R Shapiro wrote:
  12. > > 
  13. > > I'd like to use the formal argument to a template as the qualifier of a
  14. > > qualified typename within the template. This doesn't work in CodeWarrior
  15. > > 8, it does work in VC++ 4.0, and I can't tell from ARM whether or not it
  16. > > *should* work.
  17. > > 
  18. > > Here's a more specific example:
  19. > > 
  20. > > template <class OBJECT>
  21. > > class OrderedCollection {
  22. > >    typedef void (OBJECT::*memberMapper)(void);
  23. > > .
  24. > > .
  25. > > .
  26. > > };
  27. > > 
  28. > > I would like the typedef 'memberMapper' to refer to pointers to member
  29. > > functions (of no arguments and returning no value) of whatever class is
  30. > > specified in a given instantiation of the template.
  31.  
  32. I found this in the sep 95 working paper. This is in section 14.2 Template
  33. name resolution.
  34.  
  35.    2 In a template, any use of a qualified-name where the qualifier depends
  36.      on  a  template-parameter  can  be prefixed by the keyword typename to
  37.      indicate that the qualified-name denotes a type.
  38.           elaborated-type-specifier:
  39.  
  40.                   typename ::opt nested-name-specifier identifier 
  41.                                  full-template-argument-listopt
  42.  
  43.    3 If a specialization of that template  is  generated  for  a  template-
  44.      argument such that the qualified-name does not denote a type, the speĀ”
  45.      cialization is ill-formed.  The keyword typename states that the  folĀ”
  46.      lowing  qualified-name names a type.  [Note: but gives no clue to what
  47.      that type might be.  ] The qualified-name shall  include  a  qualifier
  48.      containing a template parameter or a template class name.
  49.  
  50. I have not yet tried it out w/ cw8, but the draft standard has anticipated
  51. your usage. I hope this helps.
  52.  
  53. \p
  54. -- 
  55. ObDisclaimer: #include <Disclaimer.h>
  56. ObQuote:      Chi non ha paura di morire muore una volta sola. 
  57.                       - Giovanni Falcone
  58.